Skip to content

bugfix(controlbar): Fix possible divisions by zero in Control Bar code#2867

Open
Caball009 wants to merge 1 commit into
TheSuperHackers:mainfrom
Caball009:fix_zero_division_sciences_controlbar
Open

bugfix(controlbar): Fix possible divisions by zero in Control Bar code#2867
Caball009 wants to merge 1 commit into
TheSuperHackers:mainfrom
Caball009:fix_zero_division_sciences_controlbar

Conversation

@Caball009

@Caball009 Caball009 commented Jul 12, 2026

Copy link
Copy Markdown

Using the modified rank file in #797, there are two more places the game would crash because of a division by zero; in ControlBar::populatePurchaseScience and ControlBar::updateContextPurchaseScience.

Issue reproduction steps:

  1. Add the modified rank ini data to a custom map.
  2. Start a match and click on the special powers menu.
  3. Game crashes due to a division by zero.

Callstacks:

generalszh.exe!ControlBar::populatePurchaseScience(Player * player) Line 430
generalszh.exe!ControlBar::showPurchaseScience() Line 2977
generalszh.exe!ControlBar::togglePurchaseScience() Line 3016
generalszh.exe!ControlBarSystem(GameWindow * window, unsigned int msg, unsigned int mData1, unsigned int mData2) Line 418
generalszh.exe!GameWindowManager::winSendSystemMsg(GameWindow * window, unsigned int msg, unsigned int mData1, unsigned int mData2) Line 705
generalszh.exe!GadgetPushButtonInput(GameWindow * window, unsigned int msg, unsigned int mData1, unsigned int mData2) Line 218
generalszh.exe!GameWindowManager::winSendInputMsg(GameWindow * window, unsigned int msg, unsigned int mData1, unsigned int mData2) Line 724
generalszh.exe!GameWindowManager::winProcessMouseEvent(GameWindowMessage msg, ICoord2D * mousePos, void * data) Line 919
generalszh.exe!WindowTranslator::translateGameMessage(const GameMessage * msg) Line 242
generalszh.exe!MessageStream::propagateMessages() Line 1090
generalszh.exe!GameEngine::update() Line 910
generalszh.exe!Win32GameEngine::update() Line 91
generalszh.exe!GameEngine::execute() Line 983
generalszh.exe!GameMain() Line 55
generalszh.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 929
generalszh.exe!ControlBar::updateContextPurchaseScience() Line 495
generalszh.exe!ControlBar::update() Line 1530
generalszh.exe!InGameUI::update() Line 2093
generalszh.exe!W3DInGameUI::update() Line 370
generalszh.exe!SubsystemInterface::UPDATE() Line 131
generalszh.exe!GameClient::update() Line 781
generalszh.exe!W3DGameClient::update() Line 94
generalszh.exe!SubsystemInterface::UPDATE() Line 131
generalszh.exe!GameEngine::update() Line 910
generalszh.exe!Win32GameEngine::update() Line 91
generalszh.exe!GameEngine::execute() Line 983
generalszh.exe!GameMain() Line 55
generalszh.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 929

@Caball009 Caball009 added Bug Something is not working right, typically is user facing GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Crash This is a crash, very bad labels Jul 12, 2026
@greptile-apps

greptile-apps Bot commented Jul 12, 2026

Copy link
Copy Markdown

Greptile Summary

This PR prevents rank-progress division errors in the Special Powers UI.

  • Guards non-positive rank-point ranges.
  • Resets invalid progress values to zero.
  • Updates both initial and recurring progress refresh paths.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
Core/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp Guards rank-progress division in both Special Powers UI refresh paths.

Reviews (2): Last reviewed commit: "bugfix(controlbar): Fix possible divisio..." | Re-trigger Greptile

Comment thread Core/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
@Caball009 Caball009 force-pushed the fix_zero_division_sciences_controlbar branch from 47b4cdc to 2ac70a7 Compare July 12, 2026 12:07
@Caball009 Caball009 changed the title bugfix(controlbar): Fix possible divisions by zero in ControlBar code bugfix(controlbar): Fix possible divisions by zero in Control Bar code Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Crash This is a crash, very bad Gen Relates to Generals GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant